package com.example.jiaoziyang.widgettest_403yb;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import org.w3c.dom.Text;

import java.sql.SQLOutput;

public class NewActivity extends AppCompatActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new);
        //收参数
        Intent intent =getIntent();
        String str=intent.getStringExtra("param1");
        int n= intent.getIntExtra("param2",10);
        //在logcat中显示
        System.out.println("----"+str+"--"+String.valueOf(n));
        //Toast中显示
        Toast.makeText(this,"----"+str+"--"+String.valueOf(n), Toast.LENGTH_SHORT).show();
        //在界面上的TestView中显示
        //首先获取textview 对于textview设置文本 用setTextview
        TextView tv= (TextView) findViewById(R.id.textView3);
        tv.setText("----"+str+"--"+String.valueOf(n));
        Button button= (Button) findViewById(R.id.button2);
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.button2:
                finish();
        }
    }
}
